<script language="javascript">
	var leveltree = {
		view: {
			showLine: false
		},
		edit: {
			drag: {
				autoExpandTrigger: true,
				prev: dropPrevLevel,
				inner: dropInnerLevel,
				next: dropNextLevel
			},
			enable: true,
			showRemoveBtn: true,
			showRenameBtn: false
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
			beforeRemove: doRemoveLevel,
			onDblClick: level_doDblClick
		}

	};
	function dropPrevLevel(treeId, nodes, targetNode) {
		var pNode = targetNode.getParentNode();
		if (pNode && pNode.dropInner === false) {
			return false;
		} else {
			for (var i=0,l=curDragNodes.length; i<l; i++) {
				var curPNode = curDragNodes[i].getParentNode();
				if (curPNode && curPNode !== targetNode.getParentNode() && curPNode.childOuter === false) {
					return false;
				}
			}
		}
		return true;
	}

	function dropInnerLevel(treeId, nodes, targetNode) {
		if (targetNode && targetNode.dropInner === false) {
			return false;
		} else {
			for (var i=0,l=curDragNodes.length; i<l; i++) {
				if (!targetNode && curDragNodes[i].dropRoot === false) {
					return false;
				} else if (curDragNodes[i].parentTId && curDragNodes[i].getParentNode() !== targetNode && curDragNodes[i].getParentNode().childOuter === false) {
					return false;
				}
			}
		}
		return true;
	}
	function dropNextLevel(treeId, nodes, targetNode) {
		var pNode = targetNode.getParentNode();
		if (pNode && pNode.dropInner === false) {
			return false;
		} else {
			for (var i=0,l=curDragNodes.length; i<l; i++) {
				var curPNode = curDragNodes[i].getParentNode();
				if (curPNode && curPNode !== targetNode.getParentNode() && curPNode.childOuter === false) {
					return false;
				}
			}
		}
		return true;
	}
	/**
	 *	删除 level	
	 **/
	function doRemoveLevel(e, treeNode) {	
		var lid = treeNode.lid ;	
		art.confirm('您确定要删除此成员吗？' , 
			function(){
				loadURL('/${orgi}/dm/cube/'+dimid+'/leveldel/'+lid+'.html',$("#levellist_div") ,null);
			} , function(){});
		return false;
	}

	/**
	 *	双击编辑	
	 **/
	function level_doDblClick(e, treeId, treeNode) {

		$("#leveledit").show();
		$("#leveledit").attr("data-id",treeNode.lid);
		$("#leveledit").attr("href","/${orgi}/dm/cube/"+cubeid+"/leveledit/"+treeNode.lid+".html");
		$("#leveledit").click();
		return !treeNode.isFirstNode;
	}



	var level =[
		<#if dim??>
		<#list dim.cubeLevel as level>
			<#if level_index != 0 >,</#if>{ id:${1000+level_index} , did:"${level.dimid!''}" , cubeid : "${dim.cubeid!''}", lid:"${level.id!''}" , pId:0, name:"${level.name!''}" , icon:"/assets/images/dimensions.png", dropInner:false,click:"loadURLWithTip('/${orgi}/dm/cube/${level.cubeid!''}/levelauth/${level.id}.html','#auth',null,false)"}
		</#list>
		</#if>	
	];

	$().ready(function() {
		var levelZtree = $.fn.zTree.init($("#levelZtree"), leveltree, level);
	});
	<#if result_msg??>alertMsg("${result_msg!''}");</#if>
</script>



	<div class="tableScrollWrap">
		<div class="ztree" id="levelZtree" style="height: 100%;"></div>
	</div>
	<i style="display:none;" data-toggle="ajax" id="leveledit" data-width="560" class="cbtn-icon-45" title="修改维度成员"></i>

